package mlz.d_interface.demo02;

import java.util.ArrayList;

//第1套方案:能打印出班级全部学生的信息;能打印班级全部学生的平均分。
public class StudentOperatorImpl1 implements StudentOperator{
    @Override
    public void printAllInfo(ArrayList<Student> students) {
        System.out.println("--打印全部学生的信息:--");
        for (int i = 0; i < students.size(); i++) {
            Student s = students.get(i);
            System.out.println("姓名:" + s.getName() + ",性别" + s.getSex() + ",分数:" + s.getScore());
        }
    }

    @Override
    public void printAvgScore(ArrayList<Student> students) {
        //定义总分
        double all = 0.0;

        for (int i = 0; i < students.size(); i++) {
            Student s = students.get(i);
            all += s.getScore();
        }
        System.out.println("平均分:" + (all) / students.size());
    }
}












